package com.dong.course.filter;

import com.dong.course.threadLocal.UserDTOThreadLocal;
import com.dong.thrift.user.dto.UserDTO;
import com.dong.user.client.filter.LoginFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class CourseLoginFilter extends LoginFilter {
    @Value("${user.edge.service.addr}")
    private String userEdgeServiceAddr;
    @Override
    protected void login(HttpServletRequest req, HttpServletResponse resp, UserDTO userDTO) {
        UserDTOThreadLocal.threadLocalInstacne.set(userDTO);
    }

    @Override
    protected  String userEdgeService() {
        return userEdgeServiceAddr;
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void destroy() {

    }
}
